// pages/movies/search/search.js
let app = getApp();
const globalData = app.globalData;

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    console.log(this.data)
  },

  bindConfirm: function (event) {
    let _this = this
    const value = event.detail.value
    wx.request({
      url: `${globalData.g_requestApi}search?q=${value}&apiKey=054022eaeae0b00e0fc068c0c0a2102a`,
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        const data = res.data
        _this.setData({
          searchData: data
        })
      }
    })
  },
  catchTapSearch: function (event) {
    let type= event.currentTarget.dataset.type
    let id= event.currentTarget.dataset.id
    wx.navigateTo({
      url: `../detail/detail?type=${type}&&id=${id}`
    })
  }
})